using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using QIHANGRECV;
namespace Csharp
{
    public partial class Form1 : Form
    {
        public string love;
        public Form1()
        {
            InitializeComponent();
        }
       
        recvexp kb;
        private void button1_Click(object sender, EventArgs e)
        {
            DataProc ds = new DataProc(OnDataProc);
            IntPtr P = Marshal.GetFunctionPointerForDelegate(ds);
            kb = new recvexp();
            kb.setCallback(P.ToInt32());
            kb.startRecv();
            GC.KeepAlive(ds);
        }
        delegate void DataProc(string msg);

        void OnDataProc(string msg)
        {
            love = msg;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            
            button2.Text = love;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            kb.stopRecv();
        }

    }
}